package net.ui.model.constlist;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringEscapeUtils;

public class ListDataContainer  {

	private String name;

	private String type;

	private String datatype;

	private String script;

	private String datasource;

	private String labelProperty;

	private String dataProperty;

	private String searchProperty;

	private String iconProperty;

	private String desc;
	
	private List<ListData> listData = new ArrayList<>();

	public ListDataContainer() {
	}

	public String getName() {
		return name;
	}

	public void setName(String aName) {
		name = aName;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getScript() {
		return StringEscapeUtils.unescapeXml(script);
	}

	public void setScript(String script) {
		this.script = StringEscapeUtils.escapeXml(script);
	}

	public String getDatasource() {
		return datasource;
	}

	public void setDatasource(String datasource) {
		this.datasource = datasource;
	}

	public String getDatatype() {
		return datatype;
	}

	public void setDatatype(String datatype) {
		this.datatype = datatype;
	}

	public String getLabelProperty() {
		return labelProperty;
	}

	public void setLabelProperty(String labelProperty) {
		this.labelProperty = labelProperty;
	}

	public String getDataProperty() {
		return dataProperty;
	}

	public void setDataProperty(String dataProperty) {
		this.dataProperty = dataProperty;
	}

	public String getSearchProperty() {
		return searchProperty;
	}

	public void setSearchProperty(String searchProperty) {
		this.searchProperty = searchProperty;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public String getIconProperty() {
		return iconProperty;
	}

	public void setIconProperty(String iconProperty) {
		this.iconProperty = iconProperty;
	}

	public List<ListData> getListData() {
		return listData;
	}
	
	public void addListData(ListData data) {
		listData.add(data);
	}

	public Map<Object, String> toMap() {

		Map<Object, String> map = new HashMap<Object, String>();

		for (Iterator<ListData> iterator = this.listData.iterator(); iterator.hasNext();) {
			ListData type = iterator.next();
			map.put(type.getData(), type.getLabel());
		}

		return map;

	}

}